// eslint-disable-next-line @typescript-eslint/no-var-requires
const express = require('express')
const app=express()
app.use(express.static(__dirname))
let todos=[
  {id: 1,text: 'a',completed: false},
  {id: 2,text: 'b',completed: false},
  {id: 3,text: 'c',completed: false},
]
app.get('/todos',function (req,res) {
  res.json(todos)
})
app.get('/toggle/:id',function (req,res) {
  const id=req.params.id
  todos = todos.map(item => {
    if (item.id==id) {
      item.completed=!item.completed
    }
    return item
  })
  res.json({code:0})
})
app.listen(8080)
